#ifndef __SERVER_H__
#define __SERVER_H__

/* Inclusions */
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include "inclusion.h"
#include "user.h"
#include "message.h"

typedef struct
{
    User *tab;
    int size;
    int capacity;
} UserTable;

typedef struct
{
	UserTable * users;
	User * user;
	SOCKET * sock;
} ThreadArg;

/* intialisation des tables */
void InitUserTable(UserTable * Users);

/* Fonctions d'initialisation & libération de socket */
int InitServerSocket(SOCKET * sock);
void FreeServerSocket(SOCKET Sock, UserTable * Users);

/* Fonctions d'écoute du serveur */
void DetectConnect(UserTable * Users, SOCKET sock);
void * Listen(void * ptr_abstract);
void SendToAll(Message NewMessage, UserTable * Users); 

/* Fonctions de MAJ des tables */
void AddUser(UserTable * Users, User newUser); 
void RemUser(UserTable * Users, int position); 
void UserTableTestament(UserTable * Users);

int GenerateId(UserTable Users); 

void ServerTestRegression();

#endif
